//
//  SettingsCell.m
//  FunRead
//
//  Created by dllo on 15/5/28.
//  Copyright (c) 2015年 华东伟. All rights reserved.
//

#import "SettingsCell.h"

@implementation SettingsCell

- (void)dealloc
{
    [_swi release];
    [_label release];
    [super dealloc];
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if ( self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.label = [[UILabel alloc]initWithFrame:CGRectMake(20, 0, 100, 50)];
        [self.contentView addSubview:self.label];
        [self.label release];
        

        
        
        self.swi = [[MySwitch alloc]initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 70, 0, 50, 50)];
        [self.swi setOn:YES];
        
        [self.contentView addSubview:self.swi];
        [self.swi addTarget:self action:@selector(action:) forControlEvents:UIControlEventValueChanged];
        [self.swi release];
    }
    return self;
}

- (void)action:(id)sender
{
    MySwitch *switchButton = (MySwitch *)sender;
    BOOL isButtonOn = [switchButton isOn];
    if (isButtonOn) {
        // 蓝色 - 是
        [self.delegate Test1:switchButton.indentify];
        NSLog(@"%@", @"是");
    }
    else {
        [self.delegate Test2:switchButton.indentify];
        NSLog(@"%@", @"否");
        
    }
    NSLog(@"%s", __func__);
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
